// Unsupported finetunning might be changed without warning - Remove space before the script and /script!
// Speed the keyword move to and in the clouds. 0 is the fastest (instant)
// 1 is the slowest.
// < script>document["tc-adsclick-speedkeyword"]=0.8;< /script>
// Probability of a keyword to be hidden. 0 will never hide a keyword. 1 will be the fastest.
// < script>document["tc-adsclick-hide"]=0.05;< /script>
// Probability of a keyword to be relocated. 0 will never relocate. 1 will be the fastest.
// < script>document["tc-adsclick-relocate"]=0.05;< /script>
// Override the width and height of the tagclouds
// < script>document["tc-adsclick-width"]=200;document["tc-adsclick-height"]=200;< /script>
// Set a background image
// < script>document["tc-adsclick-background-image"]="";< /script>
// Minimum and maximum size of keywords.
// < script>document["tc-adsclick-keyword-minsize"]=10;document["tc-adsclick-keyword-maxsize"]=34;< /script>
// Show these colors
// < script>document["tc-adsclick-keyword-colors"]= new Array("#FF0000","#00FF00","#0000FF");< /script>
// Gabriel Klein @ AdsClick
if (document["ACTagClouds"] != "1.0") {
document["ACTagClouds"] = "1.0";
function ACTagCloudsKeyword(myLayoutDiv, myDiv) {
this.myDiv = myDiv;
this.myLayoutDiv = myLayoutDiv;
this.cx = 2000*Math.random()-2000;
this.cy = 2000*Math.random()-2000;
this.x = this.cx;
this.y = this.cx;
this.width = myDiv.offsetWidth;
this.height = myDiv.offsetHeight;
// Fix problem with IE (cut legs)
if (document.all) {
this.height = this.height+2;
myDiv.style.height = (this.height+5)+"px";
}
this.isVisible = false;
}
ACTagCloudsKeyword.prototype.setPos = function(x,y) {
this.x = x;
this.y = y;
}
ACTagCloudsKeyword.prototype.isInit = function() {
if(this.width <= 0) {
this.width = this.myDiv.offsetWidth;
this.height = this.myDiv.offsetHeight;
if(this.width <= 0 || this.height <= 0)
return false;
}
return true;
}
ACTagCloudsKeyword.prototype.setVisible = function(d) {
try {
if (!this.isInit()) return;
} catch(e) {};
this.isVisible = d;
if (d) {
this.myDiv.style.visibility = "visible";
}
else {
this.myDiv.style.visibility = "hidden";
}
}
ACTagCloudsKeyword.prototype.tick = function(xy) {
var p = document["tc-adsclick-speedkeyword"];
if (p == null) p = 0.8;
if (p<0) p = 0;
if (p>0.99) p = 0.99;
this.cx = this.cx * p + this.x * (1-p);
this.cy = this.cy * p + this.y * (1-p);
if (Math.abs(this.cx-this.x)<3) this.cx = this.x;
if (Math.abs(this.cy-this.y)<3) this.cy = this.y;
if (this.isVisible) {
this.myDiv.style.left = (this.cx+xy[0])+"px";
this.myDiv.style.top = (this.cy+xy[1])+"px";
}
}
//--
function ACTagClouds(bgColor, borderColor, fontColorA, fontColorB, keywordsList, urlBase, width, height, siteDisplayUrl, siteClickUrl, siteColor) {
this.bgColor = bgColor;
this.borderColor = borderColor;
this.fontColorA = fontColorA;
this.fontColorB = fontColorB;
this.keywordsList = keywordsList;
this.urlBase = urlBase;
this.mySpanId = "AdsClick"+(Math.random()+"xx").substring(2);
this.width = width;
this.height = height;
this.siteDisplayUrl = siteDisplayUrl;
this.siteClickUrl = siteClickUrl;
this.siteColor = siteColor;
this.minFontSize = 10;
if (document["tc-adsclick-keyword-minsize"]) this.minFontSize = document["tc-adsclick-keyword-minsize"];
this.maxFontSize = 34;
if (document["tc-adsclick-keyword-maxsize"]) this.maxFontSize = document["tc-adsclick-keyword-maxsize"];
this.coreDiv = null;
this.fakeKeyword = null;
}
ACTagClouds.prototype.doIt = function() {
document.write('');
this.waitForSpan(this);
}
ACTagClouds.prototype.waitForSpan = function(me) {
try {
var e = document.getElementById(me.mySpanId);
if (e) {
me.buildMainSpan(e);
me.buildKeywordSpan();
me.doRelocate();
return;
}
}
catch (e) {
console.info(e);
return;
}
var me = this;
setTimeout(function(){me.waitForSpan(me);}, 100);
}
ACTagClouds.prototype.layoutKeyword = function(kw) {
try {
if (!kw.isInit())
return;
} catch(e) {};
var isOverlap = false;
var count = 0;
var pad = 10;
var w = this.coreDiv.offsetWidth - kw.width - 2*pad;
var h = this.coreDiv.offsetHeight - kw.height - 2*pad;
var x;
var y;
if (w>10 && h>10) {
do {
x = Math.random() * w + pad;
y = Math.random() * h + pad;
isOverlap = false;
for (key in this.keywordsList) {
var k = this.keywordsList[key];
if (k.isVisible && k!=kw) {
var isBeforeX = x + kw.width < k.x;
var isAfterX = x > k.x + k.width;
var isBeforeY = y + kw.height < k.y;
var isAfterY = y > k.y + k.height;
if (!isBeforeX && !isAfterX) {
if (!isBeforeY && !isAfterY) {
isOverlap = true;
}
}
}
}
}
while(isOverlap && count++<10);
}
else {
isOverlap = true;
}
if (!isOverlap) {
kw.setPos(x,y);
kw.setVisible(true);
}
else {
//kw.setVisible(false);
}
}
ACTagClouds.prototype.doRelocate = function() {
// Just to do some randomness.
for (var i=0; i<=1; i+=0.1) {
for (key in this.keywordsList) {
if (Math.random()